package com.kkb.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.kkb.mapper.ResourceMapper;
import com.kkb.pojo.ResourceExample;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ResourceService {

    @Resource
    private ResourceMapper resourceMapper;

    public PageInfo<com.kkb.pojo.Resource> selectByPage(Integer pageNum, Integer pageSize, String name){
        ResourceExample resourceExample = new ResourceExample();
        ResourceExample.Criteria criteria = resourceExample.createCriteria();
        if (name!=null && !"".equals(name)){
            criteria.andNameLike("%" + name + "%");
        }
        criteria.andStateEqualTo(0);
        PageHelper.startPage(1,5);
        List<com.kkb.pojo.Resource> resources = resourceMapper.selectByExample(resourceExample);
        return new PageInfo<>(resources);
    }
}
